<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class webindex extends CI_Controller {
	
	function __construct()
	{
		parent::__construct();
		$this->load->model('msetsubmenu');
		$this->load->model('malbum');
		$this->load->model('malbumpicture');
		$this->load->model('mdescriptioncontent');
		$this->load->model('mlocation');
		$this->load->model('mlocationpicture');
		$this->load->model('mpagescontent');
		$this->load->model('mproductcontent');
		$this->load->model('mtestimonialcontent');
	}

	public function index(){
		$data['promo'] = $this->mpagescontent->getForWeb(1);
		$data['logoLabel'] = $this->mpagescontent->getForWeb(2);
		$this->load->view('webindex/home',$data);
	}
	
	public function content($idcontent,$id){
		$label = 2;
		//-------- Company Profil
		if($idcontent == 5){
			$data['flag'] = "company";
			$data['submenu'] = $this->msetsubmenu->getForWebByMenu($idcontent);
			$data['description'] = $this->mdescriptioncontent->getForWeb($id);
			$data['logoLabel'] = $this->mpagescontent->getForWeb($label);
			$this->load->view('webindex/description',$data);
		}
		//-------- gallery
		if($idcontent == 8){
			$data['album'] = $this->malbum->getForWeb();
			$data['albumDet'] = $this->malbum->getDetForWeb($id);
			$data['picture'] = $this->malbumpicture->getForWeb($id);
			$data['logoLabel'] = $this->mpagescontent->getForWeb($label);
			$this->load->view('webindex/gallery',$data);
		}
		//-------- testimoni
		if($idcontent == 9){ 
			$data['testimoni'] = $this->mtestimonialcontent->getForWeb($idcontent);
			$this->load->view('webindex/testimoni',$data);
		}
		if($idcontent == 10 || $idcontent == 11 || $idcontent == 12 || $idcontent == 13 || $idcontent == 14 || $idcontent == 15 ){ //Product
			if($id == 0){
				$data['productDet'] = $this->mproductcontent->getDetForWeb($idcontent);
			}else{
				$data['productById'] = $this->mproductcontent->getForWebById($id);
			}
			$data['titleSubmenu'] = $this->msetsubmenu->getForWeb($idcontent);
			$data['logoLabel'] = $this->mpagescontent->getForWeb($label);
			$this->load->view('webindex/product',$data);
		}
		//------- Be Golden Store
		if($idcontent == 6){
			if($id == 20 || $id == 21 || $id == 22 || $id == 24){ //Location
				$data['submenu'] = $this->msetsubmenu->getForWebByMenu($idcontent);
				$data['titleSubmenu'] = $this->msetsubmenu->getForWeb($id);
				
				$data['location'] = $this->mlocation->getForWeb($id);
				
				$locationLocal = $this->mlocation->getForWeb($id);
				$data['locationDet'] = $this->mlocationpicture->getForWeb($locationLocal[0]['id_location']);
				
				$this->load->view('webindex/location',$data);
			}
			if($id == 23){ //Description 
				$data['submenu'] = $this->msetsubmenu->getForWebByMenu(6);
				$data['description'] = $this->mdescriptioncontent->getForWeb($id);
				$data['flag'] = "store";
				$this->load->view('webindex/description',$data);
			}
		}
		//--------- How to Joint Us
		if($idcontent == 7){
			if($id == 25 || $id == 26 || $id == 27){
				$data['submenu'] = $this->msetsubmenu->getForWebByMenu(7);
				$data['description'] = $this->mdescriptioncontent->getForWeb($id);
				$data['logoLabel'] = $this->mpagescontent->getForWeb($label);
				$data['flag'] = "join";
				$this->load->view('webindex/description',$data);
			}else if($id == 31){
				$vals = array(
					'time'	 => 'TIMESTAMP',
					'img_path'	 => './captcha/',
					'img_url'	 => base_url().'captcha/',
					'font_path'	 => './path/to/fonts/texb.ttf',
					'img_width'	 => '150',
					'img_height' => 30,
					'expiration' => 3200
					);
				$cap = create_captcha($vals);
				$data['datacaptcha'] = $cap['image'];
				$this->session->set_userdata('mycaptcha', $cap['word']);
				
				$data['submenu'] = $this->msetsubmenu->getForWebByMenu(7);
				$data['flag'] = "join";
				$data['logoLabel'] = $this->mpagescontent->getForWeb($label);
				$this->load->view('webindex/formulir',$data);
			}
		}
		//--------- Be Golden Card
		if($id == 28){
			$data['submenu'] = $this->msetsubmenu->getForWebByMenu(8);
			$data['description'] = $this->mdescriptioncontent->getForWeb($id);
			$data['flag'] = "card";
			$this->load->view('webindex/description',$data);
		}
	}
	
}